<?
	include('top.php');
	include('conn.php');

	session_start();
	$msg='';
	if($_REQUEST['up']=='true' and isset($_REQUEST['name']))
	{
		$name=$_REQUEST['name'];
        mysql_set_charset('utf8');
		$sqledit="select * from customermast where status=0 and custid='".$name."'";
		$resedit=mysql_query($sqledit);
		$rowedit=mysql_fetch_assoc($resedit);		
		$custtype=$rowedit['custtype'];

	}
	if($_REQUEST['submit']=='Update')
	{

		$custtype=$_REQUEST['custtype'];
		
		$name=$_REQUEST['name'];
		$address=$_REQUEST['address'];
		$city=$_REQUEST['city'];
		$enteredby=$_SESSION['username'];
		$custid=$_REQUEST['custid'];
		$email=$_REQUEST['email'];
		$phoneno=$_REQUEST['phoneno'];
		
		$sql="update customermast set custdesc='".strtoupper($name)."',custtype='".strtoupper($custtype)."',address='".strtoupper($address)."',city='".strtoupper($city)."',email='".strtoupper($email)."',phoneno='".strtoupper($phoneno)."'	where custid= $custid";
		$res=mysql_query($sql);
		if($res)
		{
			 echo "<script>window.location.href = 'customermaster.php'</script>";
		}	
		else
		{
			$msg='';			
		}
	}	
?>
<div  align="center">
			<div ng-controller="SearchCtrl">
			<form name="custedit" action="customeredit.php" method="post">
			<input type="hidden" name="custid" id="custid" value="<?=$rowedit['custid']?>" />
			<table  cellpadding="4" id="box-table-a" cellspacing="4" border="1" width="650" bgcolor="#000000" style="background-color:#DFEBF9;">
				<tr><td colspan="3" align="center" style="text-align:center; color:#FF0000;"><?=$msg?></td></tr>
				<tr><td colspan="3" align="center" style="text-align:center; font-weight:bold;">Customer Master (Edit)</td></tr>
				<tr bgcolor="#FFFFFF">
					<td ><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">Type</label></td>
					<td ><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">:</label></td>
					<td style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">
					<select  name="custtype" id="custtype" class="smallInput" ng-model="custtype" style="width:250px; font-size:12px; font-weight:bold;" >
						<?	$s1='';
							$s2='';
							$s3='';
                            $s4='';
							if ($rowedit['custtype']=='CUSTOMER')
								$s1='selected="selected"';
							if ($rowedit['custtype']=='DISTRIBUTOR')
								$s2='selected="selected"';	
							if ($rowedit['custtype']=='AGENT')
								$s3='selected="selected"';	
                            if ($rowedit['custtype']=='CORPORATE')
    						    $s4='selected="selected"';	
						?>
							<option <?=$s1?>>CUSTOMER</option>
							<option <?=$s2?>>DISTRIBUTOR</option>
							<option <?=$s3?>>AGENT</option>
                            <option <?=$s4?>>CORPORATE</option>
						</select>
					</td>
				</tr>
				<tr bgcolor="#FFFFFF">
					<td ><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">Name</label></td>
					<td ><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">:</label></td>
					<td style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">
						<input type="text" id="name" name="name" class="smallInput" required= "" value="<?=$rowedit['custdesc']?>" ng-model="name" placeholder="Name" style="width:280px; text-align:left; font-size:12px; font-weight:bold;" />
					</td>
				</tr>
				<tr bgcolor="#FFFFFF">
					<td ><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">Address</label></td>
					<td ><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">:</label></td>
					<td style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">
					 <textarea name="address" cols="45" rows="3" class="smallInput" id="address"  ng-model="address" style="font-size:12px; text-align:left; font-weight:bold;"><?=$rowedit['address']?></textarea>
					</td>
				</tr>
				<tr bgcolor="#FFFFFF">
					<td ><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">City</label></td>
					<td ><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">:</label></td>
					<td style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">
						<input type="text" id="city" name="city" class="smallInput" required= "" ng-model="city" placeholder="City" value="<?=$rowedit['city']?>" style="width:180px; text-align:left; font-size:12px; font-weight:bold;" />
					</td>
				</tr>
				<tr bgcolor="#FFFFFF">
					<td ><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">Email</label></td>
					<td ><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">:</label></td>
					<td style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">
						<input type="text" id="email" name="email" class="smallInput" ng-model="Email" placeholder="Email" value="<?=$rowedit['email']?>"  style="width:180px;text-align:left; font-size:12px; font-weight:bold;" />
					</td>
				</tr>
				<tr bgcolor="#FFFFFF">
					<td ><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">Phone</label></td>
					<td ><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">:</label></td>
					<td style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">
						<input type="text" id="phoneno" name="phoneno" class="smallInput" ng-model="phoneno" placeholder="phoneno" value="<?=$rowedit['phoneno']?>"  style="width:180px; text-align:left; font-size:12px; font-weight:bold;" />
					</td>
				</tr>
				<tr>
					<td align="center" colspan="3" style="background-color:#BBE2EE">
					<button type="submit" class="btn" name="submit" value="Update">Update</button>
					</td>
				</tr>
			</table>
			</form>
		</div>
			
</div>
</body>
</html>
